package numberporting.service;

import javax.jws.WebService;
import numberporting.bean.*;

@WebService(targetNamespace="http://infosys.tuwien.ac.at/ait08/dto/notification",
            portName="NotificationPT", serviceName="NotificationService", endpointInterface="numberporting.service.INotificationService")
public class SMSService implements INotificationService{
    
    private CustomerStore customerStore;
    
    public SMSService(CustomerStore customerStore){
        this.customerStore = customerStore;
    }
    
    @Override
    public boolean notify_customer(Customer customer, String message) throws InvalidCustomerException, MessageTooLongException {
        //System.out.println("SMS customer notification triggered!");
        System.out.println("SMS sent to customer "+customer.getName()+":\n"+message);
        if (message.length()>140) {
            throw new MessageTooLongException("message longer than 140 characters!");
                
        }
        this.customerStore.checkCustomer(customer.getId());
        return (Math.random() < 0.5);
    }
    
}
